package com.zhangzhan.controller;

import com.zhangzhan.domain.commcon.ResponseResult;
import com.zhangzhan.domain.dto.SaveUserDto;
import com.zhangzhan.domain.entity.User;
import com.zhangzhan.domain.vo.UserInfoVo;
import com.zhangzhan.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 张一恒
 * @version 1.0
 * @description: 用户控制层
 * @date 2022/12/3 16:30
 */
@RestController
@RequestMapping("/user")
@Slf4j
public class UserController {

    @Autowired
    UserService userService;

    @GetMapping("/userInfo")
    public ResponseResult userInfo(){
        return userService.selectUserInfo();

    }

    /**
     * @description 修改用户信息
     *
     * @return com.zhangzhan.domain.commcon.ResponseResult
     * @author 31115
     * @date 2022/12/4 13:25
     */
    @PutMapping("/userInfo")
    public ResponseResult userInfoPutMap(@RequestBody UserInfoVo userInfoVo){
        return userService.putUserInfo(userInfoVo);
    }

    /**
     * @description 注册
     * @param user
     * @return com.zhangzhan.domain.commcon.ResponseResult
     * @author 31115
     * @date 2022/12/4 16:21
     */
    @PostMapping("/register")
    public ResponseResult register(@RequestBody User user){
        return userService.saveRegister(user);
    }


}
